#include "StrategyGene.h"
#include <cstdlib>

StrategyGene::StrategyGene(const string& name, int parametersSize) 
: strategyName(name), numParameters(parametersSize) 
{
    weight = StrategyGene::randomValue();
    parameters = new int[numParameters];
    for (int i = 0; i < numParameters; i++) {
        parameters[i] = StrategyGene::randomValue();
    }
}

void StrategyGene::mutateWeight() {
    weight = StrategyGene::randomValue();  // We might want to consider other mutation functions, which might be done by the GA library outside this class
}

void StrategyGene::mutateParameter(int index) {
    if (index >= 0 && index < numParameters) {
        parameters[index] = StrategyGene::randomValue();
    }
}

void StrategyGene::mutateParameters() {
    for (int i = 0; i < numParameters; i++) {
        this->mutateParameter(i);
    }
}

int StrategyGene::randomValue() {
    return rand() % 101;
}
